package org.zero.onlinesubject.common.vo;


import java.io.Serializable;

public class Result<T> implements Serializable {
    private Integer code;
    private String msg;
    private T data;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Result() {
    }

    public Result(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> Result<T> ok() {
        return new Result<>(200,"请求成功",null);
    }

    public static <T> Result<T> ok(String msg){
        return new Result<>(200,msg,null);
    }

    public static <T> Result<T> ok(T data){
        return new Result<>(200,"请求成功",data);
    }

    public static <T> Result<T> ok(String msg,T data){
        return new Result<>(200,msg,data);
    }

    public static <T> Result<T> error(){
        return new Result<>(500,"请求出差了，请重试",null);
    }

    public static <T> Result<T> error(Integer code,String msg){
        return new Result<>(code,msg,null);
    }
}
